# coding: utf-8
import time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

device = MonkeyRunner.waitForConnection()
print('go')


def manual_attack():
    # 手动点第三个技能
    for i in range(1, 30):
        device.touch(1077, 620, MonkeyDevice.DOWN_AND_UP)
        time.sleep(2)


def auto_attack():
    # 开启自动战斗
    device.touch(1222, 380, MonkeyDevice.DOWN_AND_UP)


def open_map():
    # 打开地图
    device.touch(1200, 20, MonkeyDevice.DOWN_AND_UP)
    time.sleep(2)


def close_map():
    # 关闭地图
    device.touch(1150, 40, MonkeyDevice.DOWN_AND_UP)
    time.sleep(2)


def move_to_point(x, y, sleep_time=5):
    open_map()
    device.touch(x, y, MonkeyDevice.DOWN_AND_UP)
    time.sleep(sleep_time)
    close_map()
    auto_attack()
    manual_attack()


def open_line():
    # 弹出换线
    device.touch(244, 96, MonkeyDevice.DOWN_AND_UP)
    time.sleep(3)


def go_recommend_line():
    # 换线到推荐
    device.touch(566, 222, MonkeyDevice.DOWN_AND_UP)
    time.sleep(3)
